//
//  CellFactory.m
//  nonghubao
//
//  Created by 王 文彬 on 13-3-10.
//  Copyright (c) 2013年 Chongqing Nonghubao Co., Ltd. All rights reserved.
//

#import "CellFactory.h"
#import "MoodContentViewMaker.h"
#import "ProductContentViewMaker.h"
#import "ProductContentViewLightMaker.h"
#import "RecommendContentViewMaker.h"
#import "PersonalContentViewMaker.h"
#import "CommentContentViewMaker.h"
#import "RecommentdContentViewLightMaker.h"
#import "MoodContentViewLightMaker.h"
#import "PersonalContentViewLightMaker.h"

@implementation CellFactory

// 得到一个动态的ContentView的原型实例
+ (void)makeCell:(UITableViewCell *)cell forName:(NamedCell)name
{
    switch (name) {
        case NamedCellPersonInformation:
            [PersonalContentViewMaker makePrototype:cell.contentView];
            break;
        case NamedCellDynamicMood:
            [MoodContentViewMaker makePrototype:cell.contentView];
            break;
        case NamedCellDynamicProduct:
            [ProductContentViewMaker makePrototype:cell.contentView];
            break;
        case NamedCellDynamicRecommend:
            [RecommendContentViewMaker makePrototype:cell.contentView];
            break;
        case NamedCellDynamicComment:
            [CommentContentViewMaker makePrototype:cell.contentView];
            break;
        case NamedCellDynamicMoodLight:
            [MoodContentViewLightMaker makePrototype:cell.contentView];
            break;
        case NamedCellDynamicProductLight:
            [ProductContentViewLightMaker makePrototype:cell.contentView];
            break;
        case NamedCellDynamicRecommendLight:
            [RecommentdContentViewLightMaker makePrototype:cell.contentView];
            break;
        case NamedCellPersonInformationLight:
            [PersonalContentViewLightMaker makePrototype:cell.contentView];
            break;
    }
}

// 计算一个动态的ContentView的高度
+ (float)heightForName:(NamedCell)name withDictionary:(NSDictionary *)data
{
    float height = 0.0f;
    
    switch (name) {
        case NamedCellPersonInformation:
            height = [PersonalContentViewMaker heightWithDictionary:data];
            break;
        case NamedCellDynamicMood:
            height = [MoodContentViewMaker heightWithDictionary:data];
            break;
        case NamedCellDynamicProduct:
            height = [ProductContentViewMaker heightWithDictionary:data];
            break;
        case NamedCellDynamicRecommend:
            height = [RecommendContentViewMaker heightWithDictionary:data];
            break;
        case NamedCellDynamicComment:
            height = [CommentContentViewMaker heightWithDictionary:data];
            break;
        case NamedCellDynamicProductLight:
            height = [ProductContentViewLightMaker heightWithDictionary:data];
            break;
        case NamedCellDynamicRecommendLight:
            height = [RecommentdContentViewLightMaker heightWithDictionary:data];
            break;
        case NamedCellDynamicMoodLight:
            height = [MoodContentViewLightMaker heightWithDictionary:data];
            break;
        case NamedCellPersonInformationLight:
            height = [PersonalContentViewLightMaker heightWithDictionary:data];
            break;
    }
    
    return height;
}

// 重新渲染动态的ContentView的元素
+ (void)drawCell:(UITableViewCell *)cell forName:(NamedCell)name withDictionary:(NSDictionary *)data
{
    switch (name) {
        case NamedCellPersonInformation:
            [PersonalContentViewMaker drawContentView:cell.contentView withDictionary:data];
            break;
        case NamedCellDynamicMood:
            [MoodContentViewMaker drawContentView:cell.contentView withDictionary:data];
            break;
        case NamedCellDynamicProduct:
            [ProductContentViewMaker drawContentView:cell.contentView withDictionary:data];
            break;
        case NamedCellDynamicRecommend:
            [RecommendContentViewMaker drawContentView:cell.contentView withDictionary:data];
            break;
        case NamedCellDynamicComment:
            [CommentContentViewMaker drawContentView:cell.contentView withDictionary:data];
            break;
        case NamedCellDynamicProductLight:
            [ProductContentViewLightMaker drawContentView:cell.contentView withDictionary:data];
            break;
        case NamedCellDynamicRecommendLight:
            [RecommentdContentViewLightMaker drawContentView:cell.contentView withDictionary:data];
            break;
        case NamedCellDynamicMoodLight:
            [MoodContentViewLightMaker drawContentView:cell.contentView withDictionary:data];
            break;
        case NamedCellPersonInformationLight:
            [PersonalContentViewLightMaker drawContentView:cell.contentView withDictionary:data];
            break;
    }
}

@end
